package com.wc.alorithm_luogu._二分.P1020;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2023/10/5 13:02
 * @description 导弹拦截
 * https://www.luogu.com.cn/problem/P1020
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static int[] a = new int[N], b = new int[N], c = new int[N];
    static int n;

    public static void main(String[] args) {
        String[] ss = sc.nextLine().split(" ");
        n = ss.length;
        for (int i = 1; i <= n; i++) a[i] = Integer.parseInt(ss[i - 1]);
        b[1] = c[1] = a[1];
        int bl = 1, cl = 1;

        for (int i = 2; i <= n; i++) {
            if (b[bl] >= a[i]) b[++bl] = a[i];
            else {
                int l = 1, r = bl;
                while (l < r) {
                    int mid = l + r >> 1;
                    if (b[mid] < a[i]) r = mid;
                    else l = mid + 1;
                }
                b[r] = a[i];
            }
            if (c[cl] <= a[i]) c[++cl] = a[i];
            else {
                int l = 1, r = cl;
                while (l < r) {
                    int mid = l + r >> 1;
                    if (c[mid] >= a[i]) r = mid;
                    else l = mid + 1;
                }
                c[r] = a[i];
            }
        }
//        for(int i = 1; i <= bl; i++) out.print(b[i] + " ");
        out.println(bl);
        out.println(cl);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
